package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.client.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author mqx
 * @date 2020-10-13 15:41:03
 */
@Controller
public class IndexController {

    @Autowired
    private ProductFeignClient productFeignClient;
    // 用户访问首页的控制器
    @RequestMapping({"/","index.html"})
    public String index(HttpServletRequest request){
        // index页面需要一个list
        Result result = productFeignClient.getBaseCategoryList();
        // 获取到返回值的数据并保持到作用域！
        request.setAttribute("list",result.getData());
        // 返回首页数据
        return "index/index";
    }
}
